package com.sdtv.mediunfusion.mvp.ui.outsidetask;

import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.sdtv.basemodule.annotations.CreatePresenter;
import com.sdtv.basemodule.annotations.PresenterVariable;
import com.sdtv.basemodule.base.BaseActivity;
import com.sdtv.mediunfusion.R;
import com.sdtv.mediunfusion.bean.AuditLoggingBean;
import com.sdtv.mediunfusion.mvp.contract.MainContract;
import com.sdtv.mediunfusion.mvp.presenter.AuditLogPresenter;
import com.sdtv.mediunfusion.mvp.ui.outsidetask.adapter.AudiLoggingAdapter;
import com.sdtv.mediunfusion.utils.RouterPath;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 选题的审核状态
 */
@Route(path = RouterPath.TO_TOPICLOGGING_ACTIVITY)
@CreatePresenter(presenter = AuditLogPresenter.class)
public class AuditLoggingActivity extends BaseActivity implements MainContract.AuditLoggingView {


    @BindView(R.id.logging_titleView)
    TextView titleView;
    @BindView(R.id.logging_listView)
    RecyclerView listView;
    @BindView(R.id.logging_rootView)
    LinearLayout rootView;
    //审核列表
    private AudiLoggingAdapter adapter;
    //审核记录列表
    private List<AuditLoggingBean> dataList = new ArrayList<>();
    @PresenterVariable
    AuditLogPresenter presenter;
    @Autowired
    String selectTopicTitle;
    @Autowired
    String selectTopicId;


    /**
     * 加载布局文件
     *
     * @return
     */
    @Override
    public int getLayoutId() {
        return R.layout.activity_audit_logging;
    }

    /**
     * 初始化view
     */
    @Override
    public void initView() {
        adapter = new AudiLoggingAdapter(R.layout.audit_logging_items_layout, dataList);
        listView.setLayoutManager(new LinearLayoutManager(this));
        listView.setAdapter(adapter);
        titleView.setText(selectTopicTitle);
    }

    /**
     * 获取列表数据
     */
    @Override
    public void initData() {
        presenter.getAuditLoggingList(selectTopicId);
    }

    /**
     * 设置审核记录
     *
     * @param responseList
     */
    @Override
    public void setAuditLogData(List<AuditLoggingBean> responseList) {
        adapter.setNewData(responseList);
    }

    /**
     * 显示为暂无审核记录
     */
    @Override
    public void showEmptyView() {
        adapter.setEmptyView(R.layout.audit_logging_nocontent_layout, listView);
    }

}
